import {getNowDate} from "./utils";

export const myMixin = {
  data() {
    return {
      tableData: [], // 员工信息数据总集合
      curData: [], // 当前页展示的员工数据集合
      cur: 1, // 当前页数
      totalPage: 1, // 总页数
      depts: []
    }
  },
  computed: {
    totalSize() {
      return this.tableData.length;
    },
    pageSize() {
      return this.$store.state.pageSize;
    },
    formLabelWidth() {
      return this.$store.state.formLabelWidth;
    },
    dropLabelWidth() {
      return this.$store.state.dropLabelWidth;
    }
  },
  methods: {
    /* 获取所有部门 */
    async getDepts() {
      let result = await this.$request('/employee/depts');
      this.depts = result.data;
      this.depts.unshift("");
    },
    /* 切页 */
    changePage(cur) {
      this.cur = cur;
      let start = (this.cur - 1) * this.pageSize;
      let end = start + this.pageSize;
      this.curData = this.tableData.slice(start, end);
    },
    getNowDate
  }
};